
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;

public class ActionButton: MonoBehaviour
{
    [SerializeField] private Image m_IconImage; // 图标图片
    [SerializeField] private Button m_Button; // 按钮图片

    void OnDestroy()
    {
        m_Button.onClick.RemoveAllListeners(); // 移除所有监听器
    }
    public void Init(Sprite icon, UnityAction action)
    {
        m_IconImage.sprite = icon;
        m_Button.onClick.AddListener(action); // 还需到编辑器中选中ActionButton组件，将Button分隔栏拖动到Button中
    }
}